import 'package:flutter/material.dart';

class TipRoute extends StatelessWidget {
  final String text;

  const TipRoute({Key? key, required this.text}): super(key: key);
  void _goBack(BuildContext context) => Navigator.pop(context, "123");
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Tip Route"),
        leading: IconButton(
          icon: const Icon(Icons.arrow_back_ios),
          onPressed: () => _goBack(context),
        ),
      ),
      body: Center(
        child: Column(
          children: [
            Text(text),
            Container(
              padding: const EdgeInsets.only(top: 20),
              child: TextButton(
                child: const Text("返回"),
                onPressed: () => _goBack(context),
              ),
            )
          ],
        ),
      ),
    );
  }
}

class TestTipRoute extends StatelessWidget {
  const TestTipRoute({Key? key}): super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("测试路由附带信息"),),
      body: Center(
        child: ElevatedButton(
          child: const Text("route to tip route"),
          onPressed: () async {
            final result = await Navigator.push(context, MaterialPageRoute(builder: (builder) => const TipRoute(text: "这是提示信息页")));
            print("从 tip route 页返回，附带的信息为：$result");
          },
        ),
      ),
    );
  }
}